//
//  TuijianTableViewCell.m
//  ManyCollectionView
//
//  Created by apple on 16/7/14.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "TuijianTableViewCell.h"
#import "ShangPinCVCell.h"
#define WIDTH [[UIScreen mainScreen] bounds].size.width
#define HEIGHT [[UIScreen mainScreen] bounds].size.height


static NSString *identifier = @"CELL";
@interface TuijianTableViewCell ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>

@end

@implementation TuijianTableViewCell
{
    UICollectionView *mCollectionView;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
        
        //设置单元格大小
        flowLayout.itemSize = CGSizeMake(WIDTH/2 - 15, WIDTH/2 + 20);
        flowLayout.minimumInteritemSpacing = 5;
        flowLayout.minimumLineSpacing = 5;
        flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        //边界范围
        flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
        //页眉页脚
        //创建集合视图
        mCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, (WIDTH/2 + 30)* 3) collectionViewLayout:flowLayout];
        mCollectionView.backgroundColor = [UIColor whiteColor];
        //collectionView.backgroundColor = [UIColor whiteColor];
        //设置代理属性
        mCollectionView.dataSource = self;
        mCollectionView.delegate = self;
        mCollectionView.scrollEnabled = NO;
        //注册cell
        [mCollectionView registerClass:[ShangPinCVCell class] forCellWithReuseIdentifier:identifier];
        
        [self addSubview:mCollectionView];

        
        
        
        
    }
    return self;
}


#pragma mark -- 设置分区数量
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
    
}

#pragma mark -- 设置每个分区单元格数量
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 5;
}

#pragma mark -- 自定义cell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    ShangPinCVCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    
  
        
    return cell;
    
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
